<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://xmlns.jcp.org/jsf/html"
	xmlns:f="http://xmlns.jcp.org/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://xmlns.jcp.org/jsf/facelets">

<ui:composition template="/templates/modeloGeral.xhtml">
	<ui:define name="metadata">
		<f:metadata>
			<f:viewParam name="funacao" value="#{funcionariosBean.acao}" />
			<f:viewParam name="funcod" value="#{funcionariosBean.codigo}" />

			<f:event listener="#{funcionariosBean.carregarCadastro}"
				type="preRenderView" />
		</f:metadata>
	</ui:define>
	<ui:define name="conteudo">
		<h:form id="frmFunCad">
			<p:toolbar>
				<f:facet name="left">
					<h:outputText value="Funcionários" />
				</f:facet>
			</p:toolbar>
			<h:panelGrid id="pnlFunCadDados" columns="2">
			
				<p:outputLabel value="Código" />
				<p:inputText size="10" readonly="true"
					value="#{funcionariosBean.funcionariosCadastro.id}" />

				<p:outputLabel value="Nome completo:" />
				<p:inputText maxlength="51" size="51"
					value="#{funcionariosBean.funcionariosCadastro.nome}" 
					readonly="#{funcionariosBean.acao == 'Excluir'}">
				<f:validateBean />
				</p:inputText>
				<p:outputLabel value="Função:" />
				<p:selectOneMenu value="#{funcionariosBean.funcionariosCadastro.funcao}"
				disabled="#{funcionariosBean.acao == 'Excluir'}">
				<f:validateBean />
					<f:selectItem itemValue="" itemLabel="Selecione uma função" />
					<f:selectItem itemValue="Administrador" itemLabel="Administrador" />
					<f:selectItem itemValue="Gerente" itemLabel="Gerente" />
				</p:selectOneMenu>

				<p:outputLabel value="CPF:" />
				<p:inputMask mask="999.999.999-99" size="15"
					value="#{funcionariosBean.funcionariosCadastro.cpf}" 
					readonly="#{funcionariosBean.acao == 'Excluir'}">
				<f:validateBean />
				</p:inputMask>

				<p:outputLabel value="Senha::" />
				<p:password maxlength="6" size="10"
					value="#{funcionariosBean.funcionariosCadastro.senha}"
					readonly="#{funcionariosBean.acao == 'Excluir'}">
					<f:validateBean />
					</p:password>
			</h:panelGrid>
			
			<h:panelGrid columns="3">
				<p:commandButton value="Novo" 
				actionListener="#{funcionariosBean.novo}"
				update=":frmFunCad:pnlFunCadDados"
				rendered="#{funcionariosBean.acao == 'Novo'}"/>
				
			<p:commandButton value="Salvar" 
				actionListener="#{funcionariosBean.salvar}"
				update=":msgGlobal :frmFunCad:pnlFunCadDados"
				rendered="#{funcionariosBean.acao == 'Novo'}"/>
				
				<p:commandButton value="Excluir" 
				actionListener="#{funcionariosBean.excluir}"
				update=":msgGlobal"
				rendered="#{funcionariosBean.acao == 'Excluir'}"/>
				
				<p:commandButton value="Editar" 
				actionListener="#{funcionariosBean.editar}"
				update=":msgGlobal"
				rendered="#{funcionariosBean.acao == 'Editar'}"/>
					
				<p:button value="Voltar"
					outcome="/pages/funcionariosPesquisa.xhtml?faces-redirect=true" />
			</h:panelGrid>



		</h:form>
	</ui:define>

</ui:composition>

</html>